﻿<%@ Page Language="C#" MasterPageFile="~/Common.Master" AutoEventWireup="true" CodeBehind="disk.aspx.cs" Inherits="Pan.disk" %>
<%@ MasterType VirtualPath="~/Common.Master" %>

<asp:Content ContentPlaceHolderID="Head" runat="server">
    <link rel="stylesheet" type="text/css" href="/static/css/disk.css" />
    <script src="/static/js/disk.js"></script>
    <title>文件列表 - 网盘</title>
</asp:Content>

<asp:Content ContentPlaceHolderID="Content" runat="server">
    <div class="layui-body layui-tab-content main">
        <div class="location">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>
                    <span style="margin-right: 10px;">当前位置:</span>
                    <span class="layui-breadcrumb"><%=breadcrumb%></span>
                </legend>
            </fieldset>
        </div>
        <div class="bar">
            <button type="button" id="upload" class="layui-btn layui-btn-primary layui-btn-radius" onClick="Content_Uploader.click()"><i class="layui-icon layui-icon-upload"></i>上传文件</button>
            <button type="button" id="mkdir" class="layui-btn layui-btn-radius"><i class="layui-icon layui-icon-add-1"></i>新建文件夹</button>
            <button type="button" id="delfile" class="layui-btn layui-btn-danger layui-btn-radius"><i class="layui-icon layui-icon-delete"></i>批量删除</button>
            <button type="button" id="mkshare" class="layui-btn layui-btn-normal layui-btn-radius"><i class="layui-icon layui-icon-share"></i>批量分享</button>
        </div>
        <div class="table" runat=server>
            <asp:SqlDataSource ID="SqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:PanConnectionString %>" SelectCommand="GetFileListByPage" SelectCommandType="StoredProcedure">
                <SelectParameters>
                    <asp:QueryStringParameter Name="pid" QueryStringField="path" Type="Int32" />
                    <asp:SessionParameter Name="uid" SessionField="uid" Type="Int32" />
                    <asp:QueryStringParameter Name="page" QueryStringField="page" Type="Int32" />
                </SelectParameters>
            </asp:SqlDataSource>
            <asp:ListView ID="FileListView" runat="server" DataKeyNames="id" DataSourceID="SqlDataSource">
                <EmptyDataTemplate>
                    <table id="filelist" lay-filter="filelist" style="display: none;">
                        <thead>
                            <tr>
                                <th lay-data="{type:'checkbox', fixed: 'left'}"></th>
                                <th lay-data="{hide: true}"></th>
                                <th lay-data="{hide: true}"></th>
                                <th lay-data="{hide: true}"></th>
                                <th lay-data="{width:600}">文件名</th>
                                <th lay-data="{width:120}">文件大小</th>
                                <th lay-data="{width:220}">创建时间</th>
                                <th lay-data="{fixed:'right'}"></th>
                            </tr>
                        </thead>
                    </table>
                </EmptyDataTemplate>
                <ItemTemplate>
                    <tr>
                        <td></td>
                        <td><%# Eval("id") %></td>
                        <td><%# Eval("type") %></td>
                        <td><%# Eval("code") %></td>
                        <td><%# int.Parse(Eval("type").ToString()) == 0 ? "<i class=\"icon folder_icon\"></i>" : "<i class=\"icon file_icon\"></i>" %><%# "<span class=\"file_name\">"+Eval("name")+"</span>" %></td>
                        <td><%# string.IsNullOrEmpty(Eval("fsize").ToString()) ? "-" : Convert.ToDouble(Eval("fsize"))/1024.0 >= 1 ? (Convert.ToDouble(Eval("fsize"))/1024.0).ToString("#0.00")  + " MB" : Convert.ToDouble(Eval("fsize")).ToString("#0.00") +" KB"%></td>
                        <td><%# Eval("createTime") %></td>
                        <td></td>
                    </tr>
                </ItemTemplate>
                <LayoutTemplate>
                    <table id="filelist" lay-filter="filelist" style="display: none;">
                        <thead>
                            <tr>
                                <th lay-data="{type:'checkbox', fixed: 'left'}"></th>
                                <th lay-data="{field:'id', hide: true}"></th>
                                <th lay-data="{field:'type', hide: true}"></th>
                                <th lay-data="{field:'code', hide: true}"></th>
                                <th lay-data="{field:'filename', width:600, sort: true, event:'check'}">文件名</th>
                                <th lay-data="{field:'filesize', width:120, sort: true, align:'center'}">文件大小</th>
                                <th lay-data="{field:'filetime', width:220, sort: true, align:'center'}">创建时间</th>
                                <th lay-data="{fixed:'right', align:'center', toolbar: '#option'}"></th>
                            </tr>
                        </thead>
                        <script type="text/html" id="option">
                            <a class="layui-btn layui-btn-xs" lay-event="down">下载</a>
                            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
                            <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="share">分享</a>
                        </script>
                        <tbody runat="server">
                            <tr id="itemPlaceholder" runat="server"></tr>
                        </tbody>
                    </table>
                </LayoutTemplate>
            </asp:ListView>
            <div id="page" class="layui-table-page"></div>
            <script>
                layui.use(['table', 'laypage'], function () {
                    var table = layui.table
                    var laypage = layui.laypage
                    table.init('filelist', { height: 'full-260', limit: 12 });
                    regex = new RegExp(/&page=(\d*)/)
                    laypage.render({
                        elem: 'page',
                        count: <%=filecount%>,
                        limit: 12,
                        curr: location.href.match(regex)[1],
                        prev: '<i class="layui-icon layui-icon-left"></i>',
                        next: '<i class="layui-icon layui-icon-right"></i>',
                        layout: ['prev', 'page', 'next', 'count'],
                        jump: function (obj, first) {
                            if (!first) {
                                location.href = regex.test(location.href) ? location.href.replace(regex, '&page=' + obj.curr) : location.href + '&page=' + obj.curr
                            }
                        }
                    })
                })
            </script>
        </div>
    </div>
    <form runat="server" Style="visibility: hidden; width: 0; height: 0;">
        <asp:FileUpload ID="Uploader" runat="server" onchange="javascript:__doPostBack('ctl00$Content$doPost','')"/>
        <asp:TextBox ID="Method" runat="server"></asp:TextBox>
        <asp:TextBox ID="Value" runat="server"></asp:TextBox>
        <asp:LinkButton ID="doPost" runat="server" OnClick="doPost_Click"></asp:LinkButton>
    </form>
</asp:Content>
